# -*- coding: utf-8 -*-
# @Time    : 2021/4/17 12:34
# @Author  : Chen
# @Email   : 2356458272@qq.com
# @File    : 快速排序.py
# @Software: PyCharm

def ks(k):
    x = 0
    y = 0
    if len(k) == 1:
        return k
    else:
        while y < len(k)-1:
            for i in range(1, len(k)):
                if k[i] <= k[x]:
                    k.insert(x, k[i])
                    del k[i+1:i+2]
                    x += 1
                    y += 1
                else:
                    y += 1
        if len(k) < 3:
            return k
        else:
            if len(k[0:x]) == None:
                return ks(k[0])+k[x:x+1]+ks(k[x+1:])
            else:
                return ks(k[0:x]) + k[x:x + 1] + ks(k[x + 1:])
print(ks([2, 1, 3, 5, 10, 4, 6, 9, 0]))

    # b = k[0:x]
    # c = k[x:]
    # return ks(b)+ks(c)


#1 2 3 5 1 8 6 9
#1 1     2    3 5 8 6 9
#1    1     2    3     5 8 6 9
#1    1     2    3     5     8 6 9
#1    1     2    3     5     6    8     9

